home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Amiga Classic Collection
/
The Amiga Classic Collection - Disc 1.iso
/
Business
/
BU11-AddressMgr.DMS
/
BU11-AddressMgr.adf
/
programming_tips_code
/
amiga.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-08
|
5KB
|
250 lines
/* ----------------------------------------------------------------- */
/* amiga.c - intuition code */
#include "amiga.h"
UBYTE AmigaProg(void)
{
UBYTE error_number=NO_ERROR;
ULONG port_mask;
struct Message *message_p;
SetRast(g_rastport_p,BLUE);
RefreshWindowFrame(g_window_p);
WriteBoxText(&intuitext1,XPOS1,LINEPOS1,MESSAGE0,BLUE,OFFSET);
ActivateWindow(g_window_p);
port_mask=(1<<g_window_p->UserPort->mp_SigBit);
do {
Wait(port_mask);
while (message_p=(struct Message *)GT_GetIMsg(g_window_p->UserPort))
{
error_number=IntuitionEvent((struct IntuiMessage *)message_p);
}
}while(error_number!=PROGRAM_EXIT);
return(error_number);
}
/* ----------------------------------------------------------------- */
UBYTE IntuitionEvent(struct IntuiMessage *message_p)
{
UBYTE error_number=NO_ERROR;
UWORD code;
ULONG class;
class=message_p->Class;
code= message_p->Code;
GT_ReplyIMsg(message_p);
switch (class) {
case IDCMP_CLOSEWINDOW:
error_number=PROGRAM_EXIT; break;
case IDCMP_ACTIVEWINDOW:
WindowToFront(g_window_p);
break;
case IDCMP_INACTIVEWINDOW:
break;
case IDCMP_MENUPICK:
error_number=MenuEvent(code);
break;
default: error_number=PROGRAM_EXIT;
break;
}
return(error_number);
}
/* ----------------------------------------------------------------- */
UBYTE MenuEvent(UWORD code)
{
UBYTE error_number=NO_ERROR;
UWORD menu_number, item_number, i;
if (code!=MENUNULL)
{
menu_number=MENUNUM(code);
item_number=ITEMNUM(code);
OffMenu(g_window_p,SHIFTMENU(0)|SHIFTITEM(NOITEM));
OffMenu(g_window_p,SHIFTMENU(1)|SHIFTITEM(NOITEM));
switch(menu_number)
{
case 0: error_number=PROGRAM_EXIT; break;
case 1: for(i=0;i<4;i++)
{
WriteBoxText(&intuitext1,
XPOS1,LINEPOS1,message[i],GREY,OFFSET);
SetTimer(0,(item_number+1)*666666);
}
WriteBoxText(&intuitext1,
XPOS1,LINEPOS1,MESSAGE0,BLUE,OFFSET);
break;
default: break;
}
OnMenu(g_window_p,SHIFTMENU(1)|SHIFTITEM(NOITEM));
OnMenu(g_window_p,SHIFTMENU(0)|SHIFTITEM(NOITEM));
}
return(error_number);
}
/* ----------------------------------------------------------------- */
void __regargs SetTimer(ULONG seconds, ULONG microseconds)
{
g_timer_request_p->tr_time.tv_secs=seconds;
g_timer_request_p->tr_time.tv_micro=microseconds;
DoIO((struct IORequest *)g_timer_request_p);
}
/* ----------------------------------------------------------------------- */
void WriteBoxText(struct IntuiText *itext_p, WORD x, WORD y, UBYTE *text_p, UBYTE colour, UBYTE offset)
{
LONG length;
LONG height;
height=g_window_p->IFont->tf_YSize;
itext_p->IText=text_p;
itext_p->LeftEdge=x;
itext_p->TopEdge=y;
length=IntuiTextLength(itext_p);
if (length) {
SetAPen(g_rastport_p,colour);
RectFill(g_rastport_p,
itext_p->LeftEdge-offset,
itext_p->TopEdge-offset,
itext_p->LeftEdge+length+offset,
itext_p->TopEdge+height+offset);
DrawBevelBox(g_rastport_p,
itext_p->LeftEdge-offset,itext_p->TopEdge-offset,
length+2*offset,height+2*offset,
GT_VisualInfo, g_visual_info_p,
GTBB_Recessed, TRUE,
TAG_DONE);
PrintIText(g_rastport_p,itext_p,0,0);
}
}
/* ----------------------------------------------------------------- */
void ClearBoxText(struct IntuiText *itext_p, UBYTE colour, UBYTE offset)
{
LONG length, height;
height=g_window_p->IFont->tf_YSize;
length=IntuiTextLength(itext_p);
if (length) {
SetAPen(g_rastport_p,colour);
RectFill(g_rastport_p,
itext_p->LeftEdge-offset,
itext_p->TopEdge-offset,
itext_p->LeftEdge+length+offset,
itext_p->TopEdge+height+offset);
}
}
/* ----------------------------------------------------------------- */